package org.itsky.hystrix;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import org.itsky.User;
import org.itsky.hystrix.service.UserService;

import java.util.List;

/**
 * @Author sky
 * @Site cmtianxie163.com 2020/4/8 14:16
 */
public class UserBatchCommand extends HystrixCommand<List<User>> {

    private List<Integer> ids;
    private UserService userService;

    protected UserBatchCommand(List<Integer> ids, UserService userService) {
        super(HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("batchCmd")));
        this.ids = ids;
        this.userService=userService;
    }


    @Override
    protected List<User> run() throws Exception {
        return userService.getUserByIds(ids);
    }
}
